<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
	<link rel="stylesheet" href="/css/layui.css" media="all">
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content">
		<div class="col-sm-12">
			<div class="ibox">
				<div class="ibox-body">
					<div class="layui-row">
						<div class="layui-col-xs2">&nbsp;</div>
						<div class="layui-col-xs8">
							<br/>
							<blockquote class="layui-elem-quote layui-text">
								<h1>保单查询</h1>
							</blockquote>
							  <div class="layui-form-item">
							    <label class="layui-form-label"><em style="color:red">*</em>产品编号</label>
							    <div class="layui-input-block">
							      <input type="text" id="productNo" name="productNo" placeholder="请输入产品编号" class="layui-input">
							    </div>
							  </div>
							  <div class="layui-form-item">
							    <label class="layui-form-label"><em style="color:red">*</em>车架后六位</label>
							    <div class="layui-input-block">
							      <input type="text" id="vinCode" name="vinCode" placeholder="请输入车架号后六位" class="layui-input">
							    </div>
							  </div>
							  <div class="layui-form-item" style="text-align:center">
							    <button class="layui-btn" onclick="searchBD()">查询</button>
							  </div>
							<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
							  <legend>查询结果</legend>
							</fieldset>
							<form class="layui-form" action="">
								<div class="layui-form-item">
								    <div class="layui-inline">
								      <label class="layui-form-label">车主姓名：</label>
								      <div class="layui-input-block">
								         <div class="layui-form-mid layui-word-aux" id="carHolderName"></div>
								      </div>
								    </div>
								    <div class="layui-inline">
								      <label class="layui-form-label">保单号：</label>
								      <div class="layui-input-inline">
								      	 <div class="layui-form-mid layui-word-aux" id="bdNo"></div>
								      </div>
								    </div>
								  </div>
								    <div class="layui-form-item" style="text-align:center">
								    	<input id="id" type="hidden">
									    <a class="layui-btn layui-btn-sm" href="javascript:void(0);" onclick="seeBD()">查看</a>
								    </div>
							</form>
						</div>
						<div class="layui-col-xs2">&nbsp;</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div th:include="include :: footer"></div>
	<script type="text/javascript" src="/js/layui.js"></script>
	<script>
		function searchBD() {
			if(!$("#productNo").val()) {
				layer.alert("请输入产品编号");
				return;
			}
			if(!$("#vinCode").val()) {
				layer.alert("请输入车架号后六位");
				return;
			}

			$("#carHolderName").text("");
			$("#bdNo").text("");
			$("#id").val("");
			$.ajax({
				cache : true,
				type : "GET",
				url : "/sz/bd/getBDData",
				data : {
					productNo: $("#productNo").val(),
					vinCode: $("#vinCode").val()
				},
				async : false,
				error : function(request) {
					parent.layer.alert("Connection error");
				},
				success : function(data) {
					if (data.code == 0) {
						$("#carHolderName").text(data.bd.carHolderName);
						$("#bdNo").text(data.bd.bdNo);
						$("#id").val(data.bd.id);

					} else {
						layer.alert(data.msg)
					}

				}
			});
		}
		function seeBD() {
			if(!$("#id").val()) {
				layer.alert("未查询到保单信息");
				return;
			}
			window.open("/sz/bd/visitorPrintPreview/" + $("#id").val());
		}
	</script>
</body>
</html>